const express = require("express");

const app = express();
app.use(require("cors")());
app.use(express.json());
app.use("/", express.static(__dirname + "/web"));
app.use("/admin/", express.static(__dirname + "/admin"));
app.use("/uploads", express.static(__dirname + "/uploads"));
app.set("secret", "qwerty!");
//设置跨域访问
app.all("*", (req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By", " 3.2.1");
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
});
require("./plugins/db")(app);
require("./routes/admin/index")(app);

app.listen(3000, () => {
  console.log("start http://localhost:3000");
});
